package com.pajk.user.dal.model;

import com.pajk.user.dal.model.enums.AccountChannelStatus;
import com.pajk.user.model.Entity;
import com.pajk.user.model.enums.ChannelType;

import java.io.Serializable;

/**
 * @author Haomin Liu
 */
public class AccountChannelDO extends Entity
                              implements Serializable{

    private String openId;
    private ChannelType from;
    private Long userId;
    private AccountChannelStatus status;

    public AccountChannelDO(){}

    public AccountChannelDO(String openId, ChannelType from, Long userId, AccountChannelStatus status) {
        this.openId = openId;
        this.from = from;
        this.userId = userId;
        this.status = status;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String id) {
        this.openId = id;
    }

    public ChannelType getFrom() {
        return from;
    }

    public void setFrom(ChannelType from) {
        this.from = from;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public AccountChannelStatus getStatus() {
        return status;
    }

    public void setStatus(AccountChannelStatus status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof AccountChannelDO)) return false;

        AccountChannelDO that = (AccountChannelDO) o;

        if (from != that.from) return false;
        if (openId != null ? !openId.equals(that.openId) : that.openId != null) return false;
        if (status != that.status) return false;
        if (userId != null ? !userId.equals(that.userId) : that.userId != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = openId != null ? openId.hashCode() : 0;
        result = 31 * result + (from != null ? from.hashCode() : 0);
        result = 31 * result + (userId != null ? userId.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "AccountChannelDO{" +
                "openId='" + openId + '\'' +
                ", from=" + from +
                ", userId=" + userId +
                ", status=" + status +
                '}';
    }
}
